package com.bayleaf.web.time;

import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;

import com.bayleaf.core.BayleafServlet;
import com.bayleaf.core.Model;

@WebServlet(name="time",
urlPatterns={"/time"},
initParams={ @WebInitParam(name="title", value="Time Convert!!") } )
public class TimeConverter extends BayleafServlet {

	@Override
    public String process(Model model) throws Exception{
    	
//        PrintWriter writer = res.getWriter();
//        writer.write("Hello, " + getInitParameter("message") + ", ");
//        writer.write(req.getAttribute("filterMessage") + ", ");
//        writer.write(listenerMessage + ".\n");
    	
    	
    	System.out.println(model.getString("input"));
    	
    	model.setString("result", "THIS_IS_CAMEL_CASE");
        
        return "/camelCase/StringConverter";
    }
    
	
	
	
	/**
	 * timestamp형식의 날짜를 date형식으로 바꿈
	 * @param unixTime
	 * @return date
	 */
	public String unixTimeStampToDate(int unixTime){
		long timestamp = unixTime * 1000;  // msec  
		java.util.Date d = new java.util.Date(timestamp);  
		System.out.println(d);
		return d.toString();  
	}
}
